package com.zou.controller.backstage.menu;

import com.zou.commons.domain.ReturnObject;
import com.zou.pojo.MaxMenu;
import com.zou.service.MaxMenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/backstage/menu/max")
public class MaxController {
    @Autowired
    private MaxMenuService maxMenuService;

    @GetMapping("/list")
    public String list(MaxMenu maxMenu,Model model) {
        List<MaxMenu> maxMenuList = maxMenuService.querySomeMaxMenuByMaxMenu(maxMenu);
        model.addAttribute("maxMenuList", maxMenuList);
        return "backstage/menu/max/list";
    }

    @PostMapping("/edit")
    public @ResponseBody
    Object edit(Integer id, String name) {
        return maxMenuService.editMaxMenu(id, name);
    }

    @PostMapping("/add")
    public @ResponseBody
    Object add(String name) {
        return maxMenuService.addMaxMenu(name);
    }

    @PostMapping("/del")
    public @ResponseBody
    Object del(Integer id) {
        return maxMenuService.delMaxMenuById(id);
    }
}
